package com.yonyou.brigade.rtpnr.util;

import com.yonyou.ybzboot.starter.common.constant.GlobalConstant;

/**
 * Created by Administrator on 2018/6/12.
 */
public class test {
    public static void main(String[] args) {

        String sRequestString=CreateAccountInfo();
        String identity=GetIdentityString("10010","556","c6f67653b1f54ad19df9778873f43f75",sRequestString);
        String method="XmlSubmit";
        String url="http://login.yeetm.com:9390/openapi.asmx?wsdl";
        Object result=    CXFInvoke.invoke(url,method,identity,sRequestString,"");
        System.out.println(result.toString());
        String judge= JudgeAccountByLoginID("yyts_1806121041001","1b5d1563e44f4a4b8a3db436c25c2387","MenuFL01");
         identity=GetIdentityString("10010","556","c6f67653b1f54ad19df9778873f43f75",judge);
//        Object result=    CXFInvoke.invoke(url,method,identity,judge,"");
//        System.out.println(result.toString());
        String flightOrderList=GetFlightOrderList("2018-6-12","2018-6-13","0");
        identity=GetIdentityString("10010","556","c6f67653b1f54ad19df9778873f43f75",flightOrderList);
//        Object result=    CXFInvoke.invoke(url,method,identity,flightOrderList,"");
        System.out.println(result.toString());



//
//        string sMethodName = "XmlSubmit";
//        System.Collections.Hashtable paras = new System.Collections.Hashtable();
//        paras.Add("identity", sIdentityString);
//        paras.Add("request", sRequestString);
//        paras.Add("filter", string.Empty + "");
//        string sEncoding = "UTF-8";
//        XmlDocument doc = Yeego.Core.WSCaller.WSCaller.QuerySoapWebService(sTravelAPI, sMethodName, paras, sEncoding, 1000 * 30);
//        string sReturnString = doc.InnerXml.Replace("&lt;", "<").Replace("&gt;", ">");
//        sReturnString = sReturnString.Replace("<root>", "").Replace("</root>", "").Replace("<XmlSubmitResult xmlns=\"http://tempuri.org/\">", "").Replace("</XmlSubmitResult>", "");
//        XmlDocument xmlDoc = new XmlDocument();
//        xmlDoc.LoadXml(sReturnString);
//


    }

    /// <summary>
    /// 表示用于获取认证串
    /// </summary>
    /// <param name="sTMCID"></param>
    /// <param name="sEntID"></param>
    /// <param name="sPubKey"></param>
    /// <param name="sRequest"></param>
    /// <returns></returns>
    private static  String GetIdentityString(String sTMCID, String sEntID, String sPubKey, String sRequest)
    {
        String sVerCode = Encode.getMD5(sTMCID + sEntID + sRequest + sPubKey);
        StringBuilder sbStr = new StringBuilder();
        sbStr.append("<Identity_1_0>");
        sbStr.append("<TMCID>"+sTMCID+"</TMCID>");
        sbStr.append("<EntID>"+sEntID+"</EntID>");
        sbStr.append("<VerCode>"+sVerCode+"</VerCode>");
        sbStr.append("</Identity_1_0>");
        return sbStr.toString();
    }


    private static  String CreateAccountInfo()
    {
        StringBuilder sbRequest = new StringBuilder();

        sbRequest.append("<CreateAccountInfo_1_0>");
        sbRequest.append("<UserName>"+ "未知"+"</UserName>");
        sbRequest.append("<Mobile>15901062973</Mobile>");
        sbRequest.append("<IsActivation>Y</IsActivation>");
        sbRequest.append("<Birthday></Birthday>");
        sbRequest.append("<Email></Email>");
//        sbRequest.append("<CardName></CardName>");
        sbRequest.append("<CardNo></CardNo>");
        sbRequest.append("<PassportName></PassportName>");
        sbRequest.append("<PassportNo></PassportNo>");
        sbRequest.append("<PassportDate></PassportDate>");
        sbRequest.append("<Department>/</Department>");
        sbRequest.append("<CostCenter></CostCenter>");
        sbRequest.append("<TravelRule></TravelRule>");
        sbRequest.append("<UserRole></UserRole>");
        sbRequest.append("<DepBook></DepBook>");
        sbRequest.append("<DepView></DepView>");
        sbRequest.append("<Category></Category>");
        sbRequest.append("<StaffNum></StaffNum>");
        sbRequest.append("<Sex></Sex>");
        sbRequest.append("</CreateAccountInfo_1_0>");
        return  sbRequest.toString();
    }

    private static String JudgeAccountByLoginID(String loginID,String userKey,String funCode)
    {
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append("<JudgeAccountByLoginID_1_0>");
        stringBuilder.append("<LoginID>"+loginID+"</LoginID>");
        stringBuilder.append("<UserKey>"+userKey+"</UserKey>");
        stringBuilder.append("<FunCode>"+funCode+"</FunCode>");
        stringBuilder.append("</JudgeAccountByLoginID_1_0>");
        return  stringBuilder.toString();
    }

    public static  String GetFlightOrderList(String startDt,String endDt,String lastId)
    {
        StringBuilder stringBuilder=new StringBuilder();
        stringBuilder.append("<GetFlightOrderList_1_0>");
        stringBuilder.append("<StartDt>"+startDt+"</StartDt>");
        stringBuilder.append("<EndDt>"+endDt+"</EndDt>");
        stringBuilder.append("<LastID>"+lastId+"</LastID>");
        stringBuilder.append("</GetFlightOrderList_1_0>");
        return  stringBuilder.toString();
    }



}
